<?php require_once('Connections/dis01.php'); ?>
<?php
//initialize the session
if (!isset($_SESSION)) {
  session_start();
}

// ** Logout the current user. **
$logoutAction = $_SERVER['PHP_SELF']."?doLogout=true";
if ((isset($_SERVER['QUERY_STRING'])) && ($_SERVER['QUERY_STRING'] != "")){
  $logoutAction .="&". htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_GET['doLogout'])) &&($_GET['doLogout']=="true")){
  //to fully log out a visitor we need to clear the session varialbles
  $_SESSION['MM_Username'] = NULL;
  $_SESSION['MM_UserGroup'] = NULL;
  $_SESSION['PrevUrl'] = NULL;
  unset($_SESSION['MM_Username']);
  unset($_SESSION['MM_UserGroup']);
  unset($_SESSION['PrevUrl']);
	
  $logoutGoTo = "index.php";
  if ($logoutGoTo) {
    header("Location: $logoutGoTo");
    exit;
  }
}
?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
	$data = $_POST['msg_dt'];
	$data = explode("/", $data);
    $data = $data[2]."-".$data[1]."-".$data[0];
  $insertSQL = sprintf("INSERT INTO mensagem (msg_dt, msg_titulo, msg_resumo, msg_descricao, msg_autot) VALUES (%s, %s, %s, %s, %s)",
                       GetSQLValueString($data, "date"),
                       GetSQLValueString($_POST['msg_titulo'], "text"),
                       GetSQLValueString($_POST['msg_resumo'], "text"),
                       GetSQLValueString($_POST['msg_descricao'], "text"),
                       GetSQLValueString($_POST['msg_autot'], "text"));

  mysql_select_db($database_dis01, $dis01);
  $Result1 = mysql_query($insertSQL, $dis01) or die(mysql_error());

  $insertGoTo = "msg_cad_1001.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_dis01, $dis01);
$query_ls_versiculo = "SELECT verso_id, verso_descricao FROM versiculos ORDER BY verso_id DESC";
$ls_versiculo = mysql_query($query_ls_versiculo, $dis01) or die(mysql_error());
$row_ls_versiculo = mysql_fetch_assoc($ls_versiculo);
$totalRows_ls_versiculo = mysql_num_rows($ls_versiculo);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Disseminando.com</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="templatemo_style.css" rel="stylesheet" type="text/css" />

<link rel="stylesheet" href="css/orman.css" type="text/css" media="screen" />
<link rel="stylesheet" href="css/nivo-slider.css" type="text/css" media="screen" />	

<link rel="stylesheet" type="text/css" href="css/ddsmoothmenu.css" />

<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/ddsmoothmenu.js">

/***********************************************
* Smooth Navigational Menu- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

</script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationTextarea.js" type="text/javascript"></script>
<script type="text/javascript">

ddsmoothmenu.init({
	mainmenuid: "templatemo_menu", //menu DIV id
	orientation: 'h', //Horizontal or vertical menu: Set to "h" or "v"
	classname: 'ddsmoothmenu', //class added to menu's outer DIV
	//customtheme: ["#1c5a80", "#18374a"],
	contentsource: "markup" //"markup" or ["container_id", "path_to_menu_file"]
})

</script>

<link rel="stylesheet" href="css/slimbox2.css" type="text/css" media="screen" /> 
<script type="text/JavaScript" src="js/slimbox2.js"></script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationTextarea.css" rel="stylesheet" type="text/css" />
</head>
<body id="home">	

<div id="templatemo_wrapper">

	<div id="templatemo_header">
    	<div id="site_title"><img src="images/logo_projeto.png" width="296" height="76" /></div>
        <div id="templatemo_menu" class="ddsmoothmenu">
            <ul>
                <li><a href="principal1001.php">Principal</a></li>
                <li><a href="#" class="selected">Devocional</a></li> 
<li><a href="#">Consulta</a>
                    <ul>
                        <li><a href="cs_msg1001.php">Devocional</a></li>
                  </ul>
                </li>
                <li><a href="<?php echo $logoutAction ?>">Sair</a></li>
            </ul>
            <br style="clear: left" />
        </div> <!-- end of templatemo_menu -->
    </div> <!-- END of header -->
    
    <div id="templatemo_slider"><span class="sliderframe"></span>
    	 <div class="slider-wrapper theme-orman">
            <div id="slider" class="nivoSlider">
            	<img src="images/slider/01.jpg" alt="slider image 2" title="#htmlcaption" />
                <img src="images/slider/02.jpg" alt="slider image 2" title="#htmlcaption"/>
                <img src="images/slider/03.jpg" alt="slider image 2" title="#htmlcaption" />
                <img src="images/slider/04.jpg" alt="slider image 4" title="#htmlcaption"/>
            </div>
            <div id="htmlcaption" class="nivo-html-caption">
                <strong>Contato: antoniomarcosborges2008@gmail.com</strong>.
            </div>
        </div> 
		<script type="text/javascript" src="js/jquery-1.6.1.min.js"></script>
        <script type="text/javascript" src="js/jquery.nivo.slider.pack.js"></script>
        <script type="text/javascript">
        $(window).load(function() {
            $('#slider').nivoSlider({
				controlNav:false,
   			 directionNavHide: false
			});
        });
        </script>
    </div><!-- END of templatemo_slider -->
    
    <div id="templatemo_twitter">
    	<?php echo $row_ls_versiculo['verso_descricao']; ?>
    </div> <!-- END of twitter -->
    
    <div id="templatemo_main">
    
    	<div id="templatemo_content" class="left">
        
            <h2>&nbsp;</h2>
<hr />
          <p>Data :<font color="blue"><?php
                     $data1=date("d/m/Y");
                     echo $data1;
                     ?></font></p>
          <p>Usuario Logado: <font color="blue"><?php 
                          $usuario =$_SESSION['MM_Username'];
			  echo "$usuario";
		       ?></font></p>
           <hr />
           
          <h4>Nova Mensagem :</h4>
          <p>&nbsp;</p>
          <form action="<?php echo $editFormAction; ?>" method="post" name="form1" id="form1">
            <table width="100%" align="center">
              <tr valign="baseline">
                <td width="74" nowrap="nowrap">Data :</td>
                <td width="544"><input type="text" name="msg_dt" value="<?php
                                                            $data1=date("d/m/Y");
                                                                  echo $data1;
                                                         ?>" size="12" /></td>
              </tr>
              <tr valign="baseline">
                <td nowrap="nowrap">Titulo :</td>
                <td><span id="sprytextfield1">
                  <input name="msg_titulo" type="text" value="" size="40" maxlength="255" />
                <span class="textfieldRequiredMsg">Obrigatorio.</span></span></td>
              </tr>
              <tr valign="baseline">
                <td valign="top" nowrap="nowrap">Resumo :</td>
                <td><span id="sprytextarea1">
                  <textarea name="msg_resumo" cols="42" rows="3"></textarea>
                <span class="textareaRequiredMsg">Obrigatorio.</span></span></td>
              </tr>
              <tr valign="baseline">
                <td valign="top" nowrap="nowrap">Descrição :</td>
                <td><span id="sprytextarea2">
                  <textarea name="msg_descricao" cols="42" rows="20"></textarea>
                <span class="textareaRequiredMsg">Obrigatorio.</span></span></td>
              </tr>
              <tr valign="baseline">
                <td nowrap="nowrap">Autor :</td>
                <td><input name="msg_autot" type="text" value="<?php $usuario =$_SESSION['MM_Username'];
			                                                            echo "$usuario";
			  ?>" size="30" maxlength="100" readonly="readonly" /></td>
              </tr>
              <tr valign="baseline">
                <td nowrap="nowrap" align="right">&nbsp;</td>
                <td><input type="submit" value="Cadastrar" /></td>
              </tr>
            </table>
            <input type="hidden" name="MM_insert" value="form1" />
            <br />
          <br />
    	</form>
</div>
		
        </div> <!-- END of content -->
        <div class="clear"></div>


</div> <!-- END of wrapper -->

<div id="templatemo_bottom_wrapper">
	<div id="templatemo_bottom">
    	
        <div class="col col_3">
          <iframe frameborder="0" marginwidth="0" marginheight="0" scrolling="No" width="100%" height="30" style= "position: fixed; top: 0%; left: 0%;height: 6%;width: 100%;" src="http://streaming15.hstbr.net/player/radiogospeladoradores"></iframe>
            <div class="clear"></div>
        </div>
        <div class="clear"></div>
    </div> <!-- END of bottom -->
    
</div> <!-- END of bottom wrapper -->

<div id="templatemo_footer_wrapper">
	<div id="templatemo_footer">
    	 Desenvolvido por: AntonioBorges® | <br />
         Integrando sua FÉ ao futuro. 
    </div> <!-- END of footer -->
</div> <!-- END of footer wrapper -->
<script type="text/javascript">
<!--
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1");
var sprytextarea1 = new Spry.Widget.ValidationTextarea("sprytextarea1");
var sprytextarea2 = new Spry.Widget.ValidationTextarea("sprytextarea2");
//-->
</script>
</body>
</html>
<?php
mysql_free_result($ls_versiculo);
?>
